﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Com.Framework;
using Com.Framework.Enc;
using Com.Framework.Data;
using Com.Library.DB.User;
using Com.Web.coffinegurunaru.AppLogic.Page;

namespace Com.Web.coffinegurunaru.mypage
{
	public partial class edit_profile : WebPage
	{
		public UserEntity UserInfo { get; set; }
		protected void Page_Load(object sender, EventArgs e)
		{
			this.LeftMenuType = 4;
			if (this.WebCookies.GroupType == 3)
			{
				Response.Redirect("/mypage/edit_profile_01.aspx");
			}
			if (this.IsPostBack)
			{
				UserModifyArguments arg = new UserModifyArguments();
				arg.n4UserNo = this.WebCookies.UserNo;
				if ( Request.Form["strUserPWD1"].Parse(string.Empty) != string.Empty )
					arg.strMD5PWD = Crypt.MD5HashCrypt(Request.Form["strUserPWD1"].Parse(string.Empty));
				arg.strUserName = Request.Form["strUserName"].Parse(string.Empty);
				arg.n1Question = Request.Form["n1Question"].Parse((byte)0);
				arg.strAnswer = Request.Form["strAnswer"].Parse(string.Empty);
				arg.n1JoinMotiveType = Request.Form["n1JoinMotiveType"].Parse((byte)0);
				arg.strEmail = Request.Form["strEmail1"].Parse(string.Empty) + "@" + Request.Form["strEmail2"].Parse(string.Empty);
				arg.IsEmail = Request.Form["IsEmail"].Parse(string.Empty);
				arg.CodeSex = Request.Form["CodeSex"].Parse((byte)1);
				arg.strBirthday = Request.Form["strBirthday1"].Parse(string.Empty) + "-" + Request.Form["strBirthday2"].Parse(string.Empty) + "-" + Request.Form["strBirthday3"].Parse(string.Empty);
				arg.IsLunar = Request.Form["IsLunar"].Parse(string.Empty);
				arg.strAddress1 = Request.Form["strAddress1"].Parse(string.Empty);
				arg.strPostNo = Request.Form["strPostNo1"].Parse(string.Empty) + "-" + Request.Form["strPostNo2"].Parse(string.Empty);
				arg.strHomePhone = Request.Form["strHomePhone1"].Parse(string.Empty) + "-" + Request.Form["strHomePhone2"].Parse(string.Empty) + "-" + Request.Form["strHomePhone3"].Parse(string.Empty);
				arg.strMobilePhone = Request.Form["strMobilePhone1"].Parse(string.Empty) + "-" + Request.Form["strMobilePhone2"].Parse(string.Empty) + "-" + Request.Form["strMobilePhone3"].Parse(string.Empty);
				UserModel.Modify(arg);
				Response.Write("<script>alert('정보가 변경이 되었습니다'); location.href=location.href</script>");
			}
			UserInfo = UserModel.UserInfo(this.WebCookies.UserNo);
		}
	}
}
